package com.shensi.adminCollect.controller.fleet;

import com.shensi.adminCollect.domain.fleet.FleetInfo;
import com.shensi.adminCollect.service.fleet.FleetInfoService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
/**
 * @Auther: LogicQin
 * @Date: 2023/5/10 10:37
 * @Description:
 */
@RestController
@RequestMapping("/fleet")
@Api(tags = "FleetInfoController", description = "车队管理")
public class FleetInfoController {

    private final FleetInfoService fleetInfoService;

    @Autowired
    public FleetInfoController(FleetInfoService fleetInfoService) {
        this.fleetInfoService = fleetInfoService;
    }

    @GetMapping("/fleetlist")
    @ApiOperation(value = "获取所有车队", notes = "获取所有车队信息")
    public List<FleetInfo> getAllFleets(FleetInfo fleetInfo) {
        List<FleetInfo> list =fleetInfoService.getAllFleets(fleetInfo);
        for (FleetInfo i:list){
            System.out.println("113333333333333333333333333333333111");
        }
        return fleetInfoService.getAllFleets(fleetInfo);
    }

    @GetMapping("/fleetinfo/{id}")
    @ApiOperation(value = "根据ID获取车队信息", notes = "根据车队ID获取车队详细信息")
    public FleetInfo getFleetInfoById(@PathVariable Integer id) {
        return fleetInfoService.getFleetInfoById(id);
    }

    @PostMapping("/createfleet")
    @ApiOperation(value = "创建新车队", notes = "创建新的车队信息")
    public void createFleet(@RequestBody FleetInfo fleetInfo) {
        fleetInfoService.createFleet(fleetInfo);
    }

    @PutMapping("/updatefleet/{id}")
    public void updateFleet(@PathVariable Integer id, @RequestBody FleetInfo fleetInfo) {
        fleetInfo.setId(id);
        fleetInfoService.updateFleet(fleetInfo);
    }

    @DeleteMapping("/deletefleet/{id}")
    public void deleteFleetById(@PathVariable Integer id) {
        fleetInfoService.deleteFleetById(id);
    }

    @DeleteMapping("/deletefleets")
    public void deleteFleetByIds(@RequestBody List<Integer> ids) {
        fleetInfoService.deleteFleetByIds(ids);
    }




}


